
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // static定义静态方法
        class Person{
            constructor(name,age){
                this.name = name
                this.age= age
            }
            sayHi(){
                console.log(`hi,my name is ${this.name}`)
            } 
            static creat(name,age){
                console.log(this)
                console.log(this.name)
                return new Person(name,age) 
            }
        } 
        const p1=Person.creat("zz","18")
        console.log(p1)        
        console.log(p1.age)
        // console.log(p1.sayHi)
        p1.sayHi()

    </script>
</body>
</html>